//
//  GRBarginOnGoingCell.m
//  YC_GRice
//
//  Created by luojinrong11 on 2019/4/16.
//  Copyright © 2019年 YeCai. All rights reserved.
//

#import "GRBarginOnGoingCell.h"
#import "GRbarginingCell.h"


@interface GRBarginOnGoingCell ()<UITableViewDelegate,UITableViewDataSource,GRbarginingCellDelegate>

@end

@implementation GRBarginOnGoingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self.bkView.layer setBorderWidth:0.5];
    self.bkView.layer.borderColor = [HEXCOLOR(0xFF331F) CGColor];

    [self.bkView.layer setCornerRadius:5];
    self.bkView.layer.masksToBounds = YES;
    self.bargainList.dataSource = self;
    self.bargainList.delegate = self;
    [self.bargainList registerNib:[UINib nibWithNibName:@"GRbarginingCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"barginingCell"];
}


-(void)setOnGoingArr:(NSArray *)onGoingArr{
    _onGoingArr = onGoingArr;
    [self.bargainList reloadData];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.onGoingArr.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    GRbarginingCell * barginCell = [tableView dequeueReusableCellWithIdentifier:@"barginingCell" forIndexPath:indexPath];
    barginCell.delegate = self;
    barginCell.haggleModel = self.onGoingArr[indexPath.row];
    return barginCell;
    
}

-(void)skipToBarginPage:(NSInteger)barginId {
    
    if (_delegate && [_delegate respondsToSelector:@selector(skipToBargainingPage:)]) {
        [_delegate skipToBargainingPage:barginId ];
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    GRhaggleModel * haggleModel = self.onGoingArr[indexPath.row];
    if (_delegate &&[_delegate respondsToSelector:@selector(skipToGoodDetailVC:)]) {
        [ _delegate skipToGoodDetailVC:haggleModel];
    }
    
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 151;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
